package com.testdocs.client;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.place.shared.PlaceController;
import com.testdocs.client.common.StatusBar;
import com.testdocs.client.common.WaitingPopupPanel;
import com.testdocs.client.error.RpcErrorHandler;
import com.testdocs.client.project.context.ProjectContextHolder;
import com.testdocs.client.project.create.CreateProjectView;
import com.testdocs.client.project.create.CreateProjectViewImpl;
import com.testdocs.client.project.dashboard.DashboardView;
import com.testdocs.client.project.dashboard.DashboardViewImpl;
import com.testdocs.client.signin.SignInView;
import com.testdocs.client.signin.SignInViewImpl;
import com.testdocs.client.signin.context.SignInContextHolder;
import com.testdocs.client.structure.general.GeneralPanels;
import com.testdocs.client.structure.general.GeneralPanelsImpl;
import com.testdocs.client.structure.menu.MenuPanel;
import com.testdocs.client.structure.menu.MenuPanelImpl;
import com.testdocs.client.structure.top.TopPanel;
import com.testdocs.client.structure.top.TopPanelImpl;
import com.testdocs.client.structure.work_area.WorkAreaPanel;
import com.testdocs.client.structure.work_area.WorkAreaPanelImpl;
import com.testdocs.client.test.group.TestGroupView;
import com.testdocs.client.test.group.TestGroupViewImpl;
import com.testdocs.client.test.menu.TestGroupMenu;
import com.testdocs.client.test.menu.TestGroupMenuImpl;
import com.testdocs.client.validation.Validator;
import com.testdocs.client.version.list.VersionListView;
import com.testdocs.client.version.list.VersionListViewImpl;

public class ClientFactoryImpl implements ClientFactory{
    private final EventBus eventBus = new SimpleEventBus();
    private final PlaceController placeController = new PlaceController(eventBus);
    
    private final Validator validator = new Validator();
    
    private final SignInContextHolder signInContextHolder = new SignInContextHolder(eventBus);
    private final ProjectContextHolder projectContextHolder = new ProjectContextHolder(eventBus);
    
    private CreateProjectView createProjectView = new CreateProjectViewImpl();
    private SignInView signInView = new SignInViewImpl();
    private DashboardView dashboardView = new DashboardViewImpl();
    private VersionListView versionListView = new VersionListViewImpl();
    private TestGroupView testGroupView = new TestGroupViewImpl();
    
    private TopPanel topPanel = new TopPanelImpl();
    private GeneralPanels generalPanels = new GeneralPanelsImpl();
    private WorkAreaPanel workAreaPanel = new WorkAreaPanelImpl();
    private MenuPanel menuPanel = new MenuPanelImpl();
    private TestGroupMenu testGroupMenu = new TestGroupMenuImpl();
    
    private WaitingPopupPanel waitingPopupPanel = new WaitingPopupPanel("");
    private StatusBar statusBar = new StatusBar();
    
    private RpcErrorHandler rpcErrorHandler = new RpcErrorHandler(statusBar);
    
    public EventBus getEventBus() {
    	return eventBus;
    }
    
	public PlaceController getPlaceController() {
		return placeController;
	}
	
	public Validator getValidator() {
		return validator;
	}
	
	public SignInContextHolder getSignInContextHolder() {
		return signInContextHolder;
	}
	
	public ProjectContextHolder getProjectContextHolder() {
		return projectContextHolder;
	}
	
	public CreateProjectView getCreateProjectView() {
		return createProjectView;
	}

	public SignInView getSignInView() {
		return signInView;
	}

	@Override
	public TopPanel getTopPanel() {
		return topPanel;
	}

	@Override
	public GeneralPanels getGeneralPanels() {
		return generalPanels;
	}

	@Override
	public WorkAreaPanel getWorkAreaPanel() {
		return workAreaPanel;
	}
	
	@Override
	public MenuPanel getMenuPanel() {
		return menuPanel;
	}

	@Override
	public TestGroupMenu getTestGroupMenu() {
		return testGroupMenu;
	}
	
	@Override
	public DashboardView getDashboardView() {
		return dashboardView;
	}
	
	@Override
	public VersionListView getVersionListView() {
		return versionListView;
	}
	
	@Override
	public TestGroupView getTestGroupView() {
		return testGroupView;
	}

    @Override
    public WaitingPopupPanel getWaitingPopupPanel() {
    	return waitingPopupPanel;
    }

    @Override
    public StatusBar getStatusBar() {
    	return statusBar;
    }
    
    @Override
    public RpcErrorHandler getRpcErrorHandler() {
    	return rpcErrorHandler;
    }
}
